package com.nny.demo513;

import jdk.internal.icu.impl.NormalizerImpl;

import java.util.ArrayList;
import java.util.List;
public class TestList {
    public  void addEmp(List<Emp> list,Emp emp){
        list.add(emp);
    }
public  void findAllEmp(List<Emp>list) {
    int i;
    for (i = 0; i < list.size(); i++) ;
    System.out.println(list.get(i));
}
public  Emp findEmpName(List<Emp> list,String ename){
        for (int i =0;i< list.size();i++) {
            if (ename.equals(list.get(i).getName())) {
                return list.get(i);
            }
        }
        return null;

}
public void deleteNumber(List<Emp> list,String number){
        for (int i = 0;i< list.size();i++){
            if (number.equals(list.get(i).getNumber())){
                list.remove(i);
                System.out.println(list);
            }
        }
}
public  void updateEmpAge(List<Emp> list,Emp emp){
        for (int i = 0;i< list.size();i++){
            if(emp.getNumber().equals(list.get(i).getNumber())){
                list.set(i,emp);
                System.out.println(list);
            }
        }
}
    public void addEmp(Emp emp){
        List<Emp> list = new ArrayList<>();
        list.add(emp);
    }
    public Emp updateEmpNumber(List<Emp> list, String number){
        for(int i=0;i< list.size();i++ ){
            if(number.equals(list.get(i).getNumber())){
                return list.get(i);
            }
        }
        return null;
    }
    public List<Emp>  add() {
        List<Emp> empList = new ArrayList<>();
        for (Emp emp : empList) {
            System.out.println(emp);
        }
     return  empList;
    }


    public Emp findEmpNumber(List<Emp> list, String number) {
        for (int i =0;i< list.size();i++){
            if (number.equals(list.get(i).getNumber())){
                return list.get(i);
            }
        }
        return null;
    }
}
